<template>
	<view v-if="logined">
		<u-navbar :is-back="false" title="　" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<view class="camera u-flex u-row-center">
					<u-icon name="camera-fill" color="#000000" size="48"></u-icon>
				</view>
			</view>
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="pic" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{yonghu.xingming}}</view>
				<view class="u-font-14 u-tips-color">{{yonghu.zhanghao}}</view>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28"></u-icon>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view>
		</view>

		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="star" title="收藏"></u-cell-item>
				<u-cell-item icon="photo" title="相册"></u-cell-item>
				<u-cell-item icon="coupon" title="卡券"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" title="退出" @click="quit"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
	
	<!-- 没有登陆时只显示登录 -->
	<view class="u-m-t-20" v-else="logined">
		<u-cell-group>
			<u-cell-item icon="man-add-fill" title="登录" @click="goLogin"></u-cell-item>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pic:'https://uviewui.com/common/logo.png',
				show:true,
				logined:false,
				yonghu:{xingming:"游客",zhanghao:""}
				
			}
		},
		onLoad() {
			
		},
		onShow() {
			
			//1.获取存取的用户信息
			const value=uni.getStorageSync("user");
			console.log(value);
			this.yonghu=value;
			//2.判断是否存在，不存在logined=false,存在赋值为true
			if(value){
				this.logined=true;
			}
			else{
				this.logined=false;
			}
		},
		
		//页面展示时调用
		methods: {
			goLogin(){
				uni.navigateTo({
					url:"/pages/login"
				})
			},
			//退出
			quit(){
				uni.setStorageSync("user","");
				this.logined=false;
			}
			
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
</style>
